<template>
    <el-dialog  v-bind="$attrs"
                v-on="$listeners"
                :title="title"
                @open="onOpen"
                @close="onclose"
                :close-on-click-modal="false"
                :close-on-press-escape="false">
        <el-form :model="data">
            <el-form-item label="找房需求" :label-width="formLabelWidth">
                <el-input v-model="data.entrust_demand" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="需求分析" :label-width="formLabelWidth">
                <el-input v-model="data.entrust_analyse" autocomplete="off"></el-input>
            </el-form-item>
            <template>
                <h3>按照纬度分析</h3>
                <el-tabs v-model="activeName" @tab-click="handleClick">
                    <el-tab-pane label="按照区域纬度" name="first">
                        <el-form-item label="标题" :label-width="formLabelWidth">
                            <el-input v-model="dataList[0].analyse_name" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="点评" :label-width="formLabelWidth">
                            <el-input type="textarea" v-model="dataList[0].analyse_remark" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="推荐楼盘" :label-width="formLabelWidth">
                            <el-select v-model="value" placeholder="请选择">
                                <el-option
                                        v-for="item in options"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-tab-pane>
                    <el-tab-pane label="按照预算纬度" name="second">
                        <el-form-item label="标题" :label-width="formLabelWidth">
                            <el-input v-model="dataList[0].analyse_name" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="点评" :label-width="formLabelWidth">
                            <el-input type="textarea" v-model="dataList[0].analyse_remark" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="推荐楼盘" :label-width="formLabelWidth">
                            <el-select v-model="value" placeholder="请选择">
                                <el-option
                                        v-for="item in options"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="最低首付" :label-width="formLabelWidth">
                            <el-input v-model="dataList[0].payment_min" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="最高优惠" :label-width="formLabelWidth">
                            <el-input v-model="dataList[0].discount_hig" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-tab-pane>
                    <el-tab-pane label="按照其他纬度" name="third">
                        <el-form-item label="标题" :label-width="formLabelWidth">
                            <el-input v-model="dataList[0].analyse_name" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="点评" :label-width="formLabelWidth">
                            <el-input type="textarea" v-model="dataList[0].analyse_remark" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="选择楼盘" :label-width="formLabelWidth">
                            <el-select v-model="value" placeholder="请选择">
                                <el-option
                                        v-for="item in options"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="教育" :label-width="formLabelWidth">
                            <el-input v-model="dataList[0].education" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="医疗" :label-width="formLabelWidth">
                            <el-input v-model="dataList[0].medical" autocomplete="off"></el-input>
                        </el-form-item>
                        <el-form-item label="商业" :label-width="formLabelWidth">
                            <el-input v-model="dataList[0].business" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-tab-pane>
                </el-tabs>
            </template>
            <h3>报告结论</h3>
            <el-form-item label="选择楼盘" :label-width="formLabelWidth">
                <el-input v-model="data.real_estate_name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="最高优惠" :label-width="formLabelWidth">
                <el-input v-model="dataList[0].discount_hig" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="推荐指数" :label-width="formLabelWidth">
                <el-input v-model="dataCon.con_index" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="推荐理由" :label-width="formLabelWidth">
                <el-input v-model="dataCon.report_reason" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="cancel">取 消</el-button>
            <el-button type="primary" @click="sure">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import * as api from '../utils/api'
    export default {
        name: "ZxReportDialog",
        props:['title','dataAll','dataALLList','dataAllCon','openState'],
        data(){
            return {
                data:{},
                dataList:[],
                dataCon:{},
                formLabelWidth: '120px',
                activeName: 'first',
                options: [{
                    value: '选项1',
                    label: '黄金糕'
                }, {
                    value: '选项2',
                    label: '双皮奶'
                }],
                value: ''
            }
        },
        created() {
            /* this.dataChidren=this.data.analyseList
             this.dataChidrenC=this.data.analyseList.conclusion*/
            this.data={
                entrust_id: '',
                user_id:'',
                real_estate_id:'',
                entrust_demand:'',
                entrust_time:'',
                entrust_analyse:'',
                admin_account:'',
                entrust_finish:'',
                analyseList:[
                    {
                        analyse_id:'',
                        entrust_id: '',
                        analyse_name:'',
                        analyse_remark:'',
                        real_estate_name:'',
                        house_name:'',
                        payment_min:'',
                        discount_hig:'',
                        education:'',
                        medical:'',
                        business:'',
                        conclusion:{
                            con_id:'',
                            analyse_id:'',
                            real_estate_name:'',
                            con_price:'',
                            con_index:'',
                            report_reason:''
                        },
                    }
                ],
            }
            this.dataList=this.data.analyseList
            this.dataCon=this.data.analyseList[0].conclusion

        },
        watch:{
            openState(){
                if (this.openState){
                    if (this.title==='编辑报告'||this.title==='管理报告'){
                        this.data=this.dataAll
                        this.dataList=this.dataALLList
                        this.dataCon=this.dataAllCon
                    }
                }else {
                    this.removeData()
                }
            }
        },
        methods:{
            /*取消按钮*/
            cancel(){
                this.$emit('onclose')
            },
            onOpen(){

            },
            onclose(){
                this.$emit('onclose')
            },
            handleClick(){

            },
            /*当管理、编辑、添加按钮时清空表单数据*/
            removeData(){
                this.data={
                    entrust_id: '',
                    user_id:'',
                    real_estate_id:'',
                    entrust_demand:'',
                    entrust_time:'',
                    entrust_analyse:'',
                    admin_account:'',
                    entrust_finish:'',
                    analyseList:[
                        {
                            analyse_id:'',
                            entrust_id: '',
                            analyse_name:'',
                            analyse_remark:'',
                            real_estate_name:'',
                            house_name:'',
                            payment_min:'',
                            discount_hig:'',
                            education:'',
                            medical:'',
                            business:'',
                            conclusion:{
                                con_id:'',
                                analyse_id:'',
                                real_estate_name:'',
                                con_price:'',
                                con_index:'',
                                report_reason:''
                            },
                        }
                    ],
                }
                this.dataList=this.data.analyseList
                this.dataCon=this.data.analyseList[0].conclusion
            },
            /*确定按钮*/
            sure(){
                if(this.title==='编辑报告'){
                    this.axios({
                        url:api.POST_EDITORREPORT,
                        method:'post',
                        data:{
                            entrust_id:this.data.entrust_id,
                            user_id:this.data.user_id,
                            real_estate_id:this.data.real_estate_id,
                            entrust_demand:this.data.entrust_demand,
                            entrust_time:this.data.entrust_time,
                            entrust_analyse:this.data.entrust_analyse,
                            admin_account:this.data.admin_account,
                            entrust_finish:this.data.entrust_finish,
                            analyse_name:this.dataList.analyse_name,
                            analyse_remark:this.dataList.analyse_remark,
                            house_name:this.dataList.house_name,
                            payment_min:this.dataList.payment_min,
                            discount_hig:this.dataList.discount_hig,
                            education:this.dataList.education,
                            medical:this.dataList.medical,
                            business:this.dataList.business,
                            con_id:this.dataCon.con_id,
                            analyse_id:this.dataCon.analyse_id,
                            real_estate_name:this.dataCon.real_estate_name,
                            con_price:this.dataCon.con_price,
                            con_index:this.dataCon.con_index,
                            report_reason:this.dataCon.report_reason}
                    }).then(data=>{
                        if (data.data.data.code===200){
                            this.$emit('onclose')
                            this.$emit('newEdtorData')
                            this.$message({
                                type: 'success',
                                message: '修改成功!'
                            });
                            console.log(data)
                        }
                    }).catch({

                    })
                }
            }
        }


    }
</script>

<style lang="less" scoped>

</style>